#ifndef RP2LIGHTINGEFFECT_H
#define RP2LIGHTINGEFFECT_H

#include "Rp2MaterialState.h"
#include "Rp2ShaderEffect.h"
#include "Rp2Light.h"

namespace Rp2
{

class LightingEffect : public ShaderEffect
{
	RP2_DECLARE_RTTI;
	RP2_DECLARE_NAME_ID;

public:
	LightingEffect(int iPass);
	virtual ~LightingEffect();

	// LightingEffect is the base class for all the shader effects that need
	// lighting. The derived class must implement Configure() function,
	// shaders and other parameters will be set there. 

    // After attaching and/or detaching lights, call Configure() to activate
    // the correct shader program for the current set of lights.
    int GetLightQuantity () const;
    Light* GetLight (int i) const;
    void AttachLight (Light* pkLight);
    void DetachLight (Light* pkLight);
    void DetachAllLights ();

    // Call this function after any attaching and/or detaching lights.
    virtual void Configure () = 0;

    // Enable and disable lights for multipass drawing.  The first pass is
    // responsible for handling the emissive lighting.
    virtual void SetGlobalState (int iPass, Renderer* pkRenderer,
        bool bPrimaryEffect);
    virtual void RestoreGlobalState (int iPass, Renderer* pkRenderer,
        bool bPrimaryEffect);

protected:
    ColorRGB m_kSaveEmissive;
    std::vector<LightPtr> m_kLights;
};

typedef Pointer<LightingEffect> LightingEffectPtr;
#include "Rp2LightingEffect.inl"

}

#endif